﻿using System;

namespace MotodeServer_Win
{
    class Program
    {
        private static WebListener wl;
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Motode Windows server application.");

            //start the web listener
            wl = new WebListener();
            wl.Start();

            string inputCommand = string.Empty;

            //main input loop
            while (true)
            {
                Console.Write("Command: ");
                inputCommand = Console.ReadLine();

                //output result
                Console.WriteLine(HandleInputCommand(inputCommand));
            }
        }

        /// <summary>
        /// Handles commands input into the program
        /// </summary>
        /// <param name="command">the command put in</param>
        /// <returns></returns>
        private static string HandleInputCommand(string command)
        {
            string response = string.Empty;

            if (command == "help" || command == string.Empty)
            {
                response = "Help with Motode \n\t Available commands: help, quit";
            } 
            else if (command == "quit")
            {
                Console.WriteLine("Shutting down...");
                wl.Stop();
                Environment.Exit(0);
            }

            return response;
        }
    }
}
